﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Creative85.Framework.Utilities
{
	public static class JsonUtility
	{
		private static JsonSerializerSettings settings = new JsonSerializerSettings() { DateFormatHandling = DateFormatHandling.IsoDateFormat };

		public static string ToJson(this object obj)
		{
			return JsonConvert.SerializeObject(obj, Formatting.None, settings);
		}
		public static T FromJson<T>(this string str)
		{
			return JsonConvert.DeserializeObject<T>(str, settings);
		}
        public static void FromJson(this string str, object target)
        {
            JsonConvert.PopulateObject(str, target);
        }
	}
}
